local skel = fk.CreateSkill {
  name = "#lb_leader_skill_trigger",
}


---@class Utility_LB_Kill
local LB_U = require "packages.lb_kill_utility._base"

--[[
-- 注意，全局触发技能添加到游戏比角色技能晚，无法检测开局添加的角色技能
skel:addEffect(fk.GamePrepared, {
  global = true,
  can_refresh = function (self, event, target, player, data)
    return not player:hasSkill("diy_leader_skill&", true) and
    table.find(player:getAllSkills(), function (s)
      return s:hasTag(LB_U.LeaderSkill)
    end)
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:handleAddLoseSkills(player, "diy_leader_skill&", nil, false, true)
  end,
})
--]]

--- 暂时搞到获得技能后吧
skel:addEffect(fk.EventAcquireSkill, {
  global = true,
  can_refresh = function(self, event, target, player, data)
    return target == player and data.skill:hasTag(LB_U.LeaderSkill)
  end,
  on_refresh = function(self, event, target, player, data)
    if player.seat ~= 1 or #table.filter(player.room.alive_players, function(to)
          return LB_U.CompareKingdomWith(to, player.kingdom)
        end) == 1 then
      player.room:handleAddLoseSkills(player, "-" .. data.skill.name, nil, false, true)
      -- 注意，此时机比Skill的onAcquire早
    end
  end,
})



return skel
